﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace SharpDiary.Core.Controls
{
    public class PanelVisualBorder : Panel
    {

        #region Constructors

        public PanelVisualBorder()
        {
            DoubleBuffered = true;
        }

        private bool _useBorderStyleProperty = false;

        public bool UseBorderStyleProperty
        {
            get { return _useBorderStyleProperty; }
            set { _useBorderStyleProperty = value; Invalidate(); }
        }

        #endregion

        #region Methods

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (_useBorderStyleProperty) { return; }

            Rectangle rect = this.ClientRectangle;
            rect.Width -= 1;
            rect.Height -= 1;

            ControlPaint.DrawVisualStyleBorder(e.Graphics, rect);
        }

        #endregion
    }
}
